#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 1e5 + 10;

int mu[N], n, s1[N], s2[N], p[N];
int pri[N], pnum;
bool v[N];
vec fac[N];

void init(int l) {
	mu[1] = 1;
	rep(i, 2, l) {
		if(!v[i]) pri[++pnum] = i, mu[i] = -1;
		rep(j, 1, pnum) {
			if(pri[j] * i > l) break;
			v[pri[j] * i] = true; mu[pri[j] * i] = -mu[i];
			if(i % pri[j] == 0) { mu[pri[j] * i] = 0; break; }
		}
	}
}

ll calc(int *s, int k, int x) {
	ll res = 0;
	for(auto v : fac[x / k])
		res += mu[v] * s[v * k];
	/*
	for(auto d : fac[x / k])
		rep(i, 1, n / k / d) res += s[i * k * d] * mu[d];
	*/
	return res;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	n = in; rep(i, 1, n) p[i] = in;
	init(n);
	rep(i, 1, n) {
		int b = sqrt(i);
		rep(j, 1, b) {
			if(i % j) continue;
			fac[i].eb(j);
			if(i != j * j) fac[i].eb(i / j);
		} sort(fac[i].begin(), fac[i].end());
	}
	rep(i, 1, n) for(auto v : fac[i]) s2[v]++;
	//rep(i, 1, n) s2[i]++;
	ll ans = 0;
	rep(i, 1, n) {
		vector < pair < int, ll > > pot1, pot2;
		for(auto x : fac[p[i]]) s2[x]--;
		//s2[p[i]]--;
		for(auto x : fac[p[i]]) pot1.eb(x, calc(s1, x, p[i])), pot2.eb(x, calc(s2, x, p[i]));
		for(auto x : fac[p[i]]) s1[x]++;
		//s1[p[i]]++;
		
		//for(auto v : pot1) cerr << v.fi << " " << v.se << endl;
		//cerr << endl;
		//for(auto v : pot2) cerr << v.fi << " " << v.se << endl;
		//cerr << "---" << endl;
		
		auto it1 = pot1.begin(), it2 = pot2.begin();
		ll tot2 = 0;
		for(auto v : pot2) tot2 += v.se;
		while(it1 != pot1.end() && it2 != pot2.end()) {
			if(it1->fi <= it2->fi) {
				ans += it1->se * tot2; it1++;
			} else {
				tot2 -= it2->se; it2++;
			}
		}
		while(it1 != pot1.end()) ans += it1->se * tot2;
	} printf("%lld\n", ans);
	return 0;
}
